import {LIST_PAGE_FUN} from "@/views/securityCheck/defectQuestion/listPage/subPage/config";
import {isArr} from "@/utils/arrayUtil";
import {HANDEL_CODE_CONFIG} from "@/views/securityCheck/ztDefectInspect/components/eventConfig";

const subPageMixins = {
  props: {
    inspectInfo: {
      type: Object,
      default: () => {
        return {}
      }
    },
    handelCode: {
      type: [String, Number]
    },
    nodeSerialNo:{
      type: [String, Number]
    },
    instanceNo:{
      type: [String, Number]
    },
    currentPageName: {
      type: String
    }
  },
  data() {
    return {
      HANDEL_CODE_CONFIG,
      LIST_PAGE_FUN,
    }
  },
  methods: {
    clickHandel({fun}, param) {
      if (!this[fun] || typeof this[fun] !== 'function') return;
      this[fun](param)
    },
    goInfoPage({path, id}) {
      this.$emit('goInfoPage', {path, id,})
    },
    getBtList(subType) {
      let {currentPageName, handelCode} = this
      let btItem = LIST_PAGE_FUN[currentPageName]
      if (btItem == null) return [];
      let btList = btItem[subType];
      return isArr(btList) ? btList : []
    }
  },
  created() {
    this.getList();
  },
}

export {subPageMixins}
